- fitting with Xi -
fit(func,param,x[,y][,wd][,we][,partol][,maxit][,ifixp][,ifixx] [,taufac][,sstol][,sclp][,scld][,report]) is suited for tuning parameters par in a function f to minimize the sum of squared weight orthogonal distances form the observations (x,y) to the curve determined by the parameters. Set the parameter \report to get a detailed report including the standard errors of the estimated Parameters (S.D. BETA) and the 95% confidence Interval. Example: the function f(x;b0,b1,b2):=b0+b1*(exp(b2*x)-1)^2 shall be fitted on a given set of data:
( 1)>double[] f(double x[],double b[]) ( 2)>{return b[0]+b[1]*pow(exp(b[2]*x)-1,2);} Function f defined ( 3)>beta={1500,-50,-0.1}; ( 4)>x={0,0,5,7,7.5,10,16,26,30,34,34.5,100}; ( 5)>y={1265,1263.6,1258,1254,1253,1249.8,1237,1218,1220.6,1213.8,1215.5,1212}; ( 6)>p=fit([(x;b0,b1,b2)->y:y=f(x,{b0,b1,b2});],beta,x,y); Message: sum of squares convergence ( 7)>print(p); <dblarr> 1264.6548 -54.018405 -0.087849692 ( 8)>plot(x,y,\marker=4); ( 9)>plot(x,f(x,p),\curve);
The other parameters are optional,